<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2021/7/26
  Time: 15:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <meta charset="UTF-8">
  <title>权限</title>
  <link href="static/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
  <link href="static/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
  <link href="static/css/animate.min.css" rel="stylesheet">
  <link href="static/css/myAlert.css" rel="stylesheet">
  <link href="static/css/style.min.css?v=4.0.0" rel="stylesheet"><base target="_blank">
</head>
<body>
<div class="ibox-content" style="width: 60%;margin-left: 15%;margin-top: 10%">
  <form class="form-horizontal" action="addMenu" method="post">
    <h2 style="text-align: center ;color: #07c227">添加权限</h2>
    <div class="form-group">
      <label class="col-sm-3 control-label">权限名称：</label>
      <div class="col-sm-8">
        <input type="text" placeholder="权限名称" class="form-control" name="mname"/>
        <span class="help-block"></span>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">权限路径：</label>
      <div class="col-sm-8">
        <input type="text" placeholder="权限路径" class="form-control" name="murl"/>
        <span class="help-block"></span>
      </div>
    </div>
    <div class="form-group">
      <label class="col-sm-3 control-label">父级权限：</label>
      <div class="col-sm-8">
        <select  class="btn btn-block btn-outline btn-primary mparent" name="mparent">
        <option value="0">
          ----请选择父级标签（一级菜单可不选）----
        </option>
        </select>
      </div>
    </div>
    <p>
      <button type="submit" class="btn btn-block btn-outline btn-primary" style="width: 50%;margin-left:33%">提交</button>
    </p>
  </form>
</div>
<script src="static/js/jquery.min.js?v=2.1.4"></script>
<script src="static/js/bootstrap.min.js?v=3.3.5"></script>
<script src="static/js/plugins/iCheck/icheck.min.js"></script>
<script src="static/js/myAlert.js"></script>
<script src="static/js/jquery.form.min.js"></script>
<script>
  $(function (){
    $.ajax({
      url:"findAllFirstMenu",
      type:"post",
      dataType:"json",
      success:function (data){
        for (let i = 0; i < data.length; i++) {
          $(".mparent").append(" <option value="+data[i].mid+">"+data[i].mname+"</option>")
        }
      }
    })
    var malert= {
      title: "Tip",
      msg: "操作成功",
    }
    $(".btn-primary").click(function (){
      MyAlert(malert);
    })
    //阻止form表单跳转
    $(".form-horizontal").submit(function (){
      $(this).ajaxSubmit()
      return false;
    })
  })
</script>
</body>
</html>
